import allure
from appium.webdriver.common.appiumby import AppiumBy

from .base import Base


class Search_page(Base):    # 搜索页
    # 搜索框
    __SEARCH_NAME = (AppiumBy.ID, 'com.xueqiu.android:id/search_input_text')
    # 搜索结果
    __SEARCH_RESULTS = (AppiumBy.XPATH, '//android.widget.TextView[@resource-id="com.xueqiu.android:id/name" and @text="阿里巴巴"]')

    def search(self, input_name):
        with allure.step("搜索内容,并点击"):
            self.find_key(self.__SEARCH_NAME, input_name)   # 输入内容
            self.find_click(self.__SEARCH_RESULTS)          # 点击查询到的信息
            from .search_engine_results_page import Search_engine_results_page
            return Search_engine_results_page(self.driver)
